#!/usr/bin/make -f
# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA

upstream_version := $(shell dpkg-parsechangelog | sed -n -e'/^Version: / { s/Version: //; s/-[^-]\+$$//; p }')
base_version = $(shell echo $(upstream_version) | sed -e's/r[0-9]\+$$//')

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

%:
	#dh $@ --with autoreconf
	dh  $@
# FIXME -DLIB_SUFFIX=64 ???

override_dh_auto_configure:
	cmake -G 'Unix Makefiles' \
	    -DCMAKE_INSTALL_PREFIX=/usr \
	    -DCMAKE_BUILD_TYPE=RelWithDebInfo \
	    @EXTRA_CMAKE_OPTS@ \
	    .
	DEB_BUILD_HARDENING=1 make VERBOSE=1

# Do nothing; the test suite requires a sql server, so we can't run it
# as part of the build.
override_dh_auto_test:

# we should never need to run this for our plugin package; running it creates
# a spurious shlibs file that shouldn't be there.
override_dh_shlibdeps:
	dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info

TMP_INSTDIR = $(CURDIR)/debian/tmp

PRIVATE_BINDIR = /usr/lib/mysqlsh
TMP_PRIVATE_BINDIR = $(TMP_INSTDIR)$(PRIVATE_BINDIR)

override_dh_auto_clean:

override_dh_auto_install:
	dh_auto_install -- libdir=$(PRIVATE_BINDIR) DESTDIR=$(TMP_INSTDIR)

